//
//  SFTest.swift
//  SFQuestion
//
//  Created by zyb on 2024/8/26.
//

import Foundation

struct CModel {
    var name: Int = 0
}

class CCModel {
    var name: Int
    init(name: Int) {
        self.name = name
    }
}

class CodeTest {
    let m1 = CModel(name: 1)
    let m2 = CModel(name: 2)
    let m3 = CCModel(name: 1)
    let m4 = CCModel(name: 2)
    var objArr = [CCModel]()
    
    func test() {
        var arr = [m1, m2]
        self.objArr = [m3, m4]
        
        self.modify(arr)
        self.modifyObj(self.objArr)
    }
    
    func modify(_ arr: Array<CModel>) {
        var m3 = arr[0]
        m3.name = 5
        for item in arr {
            print(item)
        }
    }
    
    func modifyObj(_ arr: Array<CCModel>) {
        print(Unmanaged.passUnretained(arr as AnyObject).toOpaque())
        print(Unmanaged.passUnretained(self.objArr as AnyObject).toOpaque())
        var m3 = arr[0]
        m3.name = 5
        for item in arr {
            print(item.name.description)
        }
    }
    
}
